<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<%@ include file="./Header.jsp"%>
			</td>
		</TR>
		<TR HEIGHT="100">
		
		<td>
		<a href="RentalList_s.jsp" class="btn btn-link btn-small">대여신청<br></a><br><br>




<%
String cmd = request.getParameter("cmd");
String selectedCategory = request.getParameter("select01");
String use_status = request.getParameter("use_status");
String ID = request.getParameter("ID");
int id;
String u = (String)session.getAttribute("userID");
int oState=0;
if(u!=null) {
if(RentalHome.OverdueExist(u) != null){
	for(Overdue o : RentalHome.OverdueExist(u)){
		oState = o.get연체번호();
	}
} 
}
%>

	<form method="post">
		<select name="select01">
			<OPTION VALUE='카테고리선택'>카테고리선택</OPTION>

			<% for (Model g : RentalHome.category()) {%>
			<OPTION VALUE="<%=g.get카테고리명()%>"
				<%=g.get카테고리명().equals(selectedCategory) ? "selected" : "" %>><%=g.get카테고리명()%></OPTION>
			<%} %>
		</SELECT> <INPUT name="cmd" class="btn btn-inverse" TYPE="submit" VALUE="찾기">
	</form>
	<%
				if ("찾기".equals(request.getParameter("cmd"))) {

			%>


	<table class="table">
			<form method="post">
		<TR>
			<TD>카테고리명</TD>
			<TD>모델명</TD>
			<TD>보관사용처</TD>
			<TD>구매날짜</TD>
			<TD>대여가능수</TD>
		</TR>

		<%
					for (EM g : RentalHome.categoryviewsp(selectedCategory)) {
						
						
				%>
<% for(EM e : RentalHome.getRentalID(selectedCategory, g.get보관사용처())){%>

		<TR class="selectableItem" onclick="document.location='EquipmentDetail_s.jsp?str_aid=<%=e.get기자재번호()%>&model_id=<%=g.get모델번호()%>'">
			<TD><%=g.get카테고리명()%></TD>
			<TD><%=g.get모델명()%></TD>
			<TD><%=g.get보관사용처()%><input type="hidden" name="use_status" value="<%=g.get보관사용처() %>"></TD>
			<TD><%=g.get구매날짜()%></TD>
<% for(EM bc : RentalHome.getModelCount(g.get모델번호(), g.get보관사용처())){%>
			<Td><%=bc.get대여가능수() %></td>
		</TR>
		
		<%	
}}}%>
		<% }%>
		</form>
	</table><%if(oState!=0){%>

<table width=100%><tr><td width=30%><h3><p align="center"><font  color="gray">
<%=(String)session.getAttribute("userName") %>님은 연체기록이 있어서 대여가 불가합니다.</font></p></h3></td>
</tr></table>

<%} %>
	<input type="hidden" name="category" value="<%= selectedCategory %>" />
	</TD>
</TR>

<TR HEIGHT="100">
<TD><%@ include file="./bottom.jsp"%></TD> 
</TR>
</TABLE>
</body>
</html>